﻿using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class OrderDetailService
    {
        /// <summary>
        /// 添加订单详情
        /// </summary>
        /// <param name="orderDetail"></param>
        /// <returns></returns>
        public static int AddOrderDetails(OrderDetail orderDetail)
        {
            using (ShopDemoContextt db = new ShopDemoContextt())
            {
                db.OrderDetail.Add(orderDetail);
                return db.SaveChanges();
            }
        }
        /// <summary>
        /// 根据客户id获取订单详情信息
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public static Product GetOrderDetailMsg(string ProductId)
        {
            using (ShopDemoContextt db = new ShopDemoContextt())
            {
                int ProductId1 = Convert.ToInt32(ProductId);
               return db.Product.FirstOrDefault(p=>p.Id==ProductId1);
            }
        }


        public static OrderDetail GetMsgOrderDetail(string Orderid)
        {
            using (ShopDemoContextt db = new ShopDemoContextt())
            {
                return db.OrderDetail.FirstOrDefault(p=>p.OrderId== Orderid);
            }
        }

    }
}
